From d4c856a57a55f888369c8933d93c6da04cd8036c Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Wed, 7 Dec 2016 13:52:59 +0100 Subject: [PATCH] libelf: use UINT_MAX MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit While Xen indeed doesn't have limits.h, it still does have UINT_MAX, so we should avoid open coding it (and perhaps - even if unlikely - getting it wrong). Signed-off-by: Jan Beulich Reviewed-by: Konrad Rzeszutek Wilk Reviewed-by: Roger Pau Monné --- xen/common/libelf/libelf-private.h | 1 + xen/common/libelf/libelf-tools.c | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/xen/common/libelf/libelf-private.h b/xen/common/libelf/libelf-private.h index d5f9d89f27..388c3da34d 100644 --- a/xen/common/libelf/libelf-private.h +++ b/xen/common/libelf/libelf-private.h @@ -43,6 +43,7 @@ #include #include #include +#include #ifdef __sun__ #include #define bswap_16(x) BSWAP_16(x) diff --git a/xen/common/libelf/libelf-tools.c b/xen/common/libelf/libelf-tools.c index 0197b85819..a5703b307e 100644 --- a/xen/common/libelf/libelf-tools.c +++ b/xen/common/libelf/libelf-tools.c @@ -131,9 +131,10 @@ unsigned elf_shdr_count(struct elf_binary *elf) { unsigned count = elf_uval(elf, elf->ehdr, e_shnum); uint64_t max = elf->size / sizeof(Elf32_Shdr); - if (max > ~(unsigned)0) - max = ~(unsigned)0; /* Xen doesn't have limits.h :-/ */ - if (count > max) + + if ( max > UINT_MAX ) + max = UINT_MAX; + if ( count > max ) { elf_mark_broken(elf, "far too many section headers"); count = max; -- 2.30.2